/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package de.swta;

import java.util.ArrayList;
import java.util.List;
import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.DefaultDataTable;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.resources.StyleSheetReference;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

/**
 *
 * @author Jan Korreck
 */
public class Categories extends WebPage {

    CategoryForm catForm = new CategoryForm("catForm");

    

    public Categories() {
        
        add(new StyleSheetReference("stylesheet", Categories.class, "style.css"));

        add(catForm);
        List<IColumn> columns = new ArrayList<IColumn>();

        

//        columns.add(new PropertyColumn(new Model("ID"), "id", "id") {
////            @Override
////            public String getCssClass()
////            {
////                return "numeric";
////            }
//        });
//
//        columns.add(new PropertyColumn(new Model("Name"), "name", "name") {
////            @Override
////            public String getCssClass()
////            {
////                return "numeric";
////            }
//        });

        columns.add(new AbstractColumn(new Model("Actions")) {

            public void populateItem(Item cellItem, String componentId, IModel model) {
                 cellItem.add(new CategoryActionPanel(componentId, model, Categories.this));
            }

        });

        columns.add(new PropertyColumn(new Model("ID"), "id"));
        columns.add(new PropertyColumn(new Model("Name"), "name"));


        add(new DefaultDataTable("categoryTable", columns, new SortableCategoryProvider(), 10));
    }

    public void editSelectedItem(Category editCat) {
        this.catForm.setModelObject(editCat);
//        ((TextField) this.catForm.get("id")).setEnabled(false);
    }


}
